home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / libraries / newiff.lha / NewIFF / NewIFF39.lha / newiff39 / iffp / iff.h < prev    next >
C/C++ Source or Header  |  1993-09-28  |  5KB  |  192 lines

  1. /* 
  2.  *
  3.  * iff.h:    General Definitions for IFFParse modules
  4.  *
  5.  * 10/20/91
  6.  * 39.5 - 11/92 - allow a conditional USE_AMIGA_IO define to cause
  7.  *   inclusion of Amiga-specific prototypes rather than standard C
  8.  *   stdlib.h and stdio.h (you must change makefile also - see notes below)
  9.  *   Added include of exec/libraries.h
  10.  */
  11.  
  12. #ifndef IFFP_IFF_H
  13. #define IFFP_IFF_H
  14.  
  15. #include "iffp/compiler.h"
  16.  
  17. #ifndef EXEC_TYPES_H
  18. #include <exec/types.h>
  19. #endif
  20. #ifndef EXEC_MEMORY_H
  21. #include <exec/memory.h>
  22. #endif
  23. #ifndef EXEC_LIBRARIES_H
  24. #include <exec/libraries.h>
  25. #endif
  26. #ifndef UTILITY_TAGITEM_H
  27. #include <utility/tagitem.h>
  28. #endif
  29. #ifndef UTILITY_HOOKS_H
  30. #include <utility/hooks.h>
  31. #endif
  32. #ifndef LIBRARIES_IFFPARSE_H
  33. #include <libraries/iffparse.h>
  34. #endif
  35.  
  36. #include <string.h>
  37.  
  38. /* If you define this, change your link to use Amiga startup code
  39.  * like astartup.obj, and to link with library amiga.lib first
  40.  */
  41. #ifdef USE_AMIGA_IO
  42. #include <clib/alib_stdio_protos.h>
  43. #else
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46. #endif
  47.  
  48. #ifndef MYDEBUG_H
  49. #include "iffp/debug.h"
  50. #endif
  51.  
  52. #ifndef NO_PROTOS
  53. #include <clib/exec_protos.h>
  54. #include <clib/utility_protos.h>
  55. #include <clib/iffparse_protos.h>
  56. #endif
  57. #ifndef NO_SAS_PRAGMAS
  58. extern struct Library *SysBase;
  59. #include <pragmas/exec_pragmas.h>
  60. extern struct Library *IFFParseBase;
  61. #include <pragmas/iffparse_pragmas.h>
  62. extern struct Library *DOSBase;
  63. #include <pragmas/dos_pragmas.h>
  64. #endif
  65.  
  66. #ifndef MAX
  67. #define    MAX(a,b)    ((a) > (b) ? (a) : (b))
  68. #endif
  69. #ifndef MIN
  70. #define    MIN(a,b)    ((a) < (b) ? (a) : (b))
  71. #endif
  72. #ifndef ABS
  73. #define    ABS(x)        ((x) < 0 ? -(x) : (x))
  74. #endif
  75.  
  76. /* Locale stuff */
  77. #ifndef LOCALESTR_IFFP_H
  78. #define CATCOMP_NUMBERS
  79. #include "iffp/iffpstrings.h"
  80. #endif
  81.  
  82. #ifndef CATCOMP_ARRAY
  83. struct CatCompArrayType
  84. {
  85.     LONG   cca_ID;
  86.     STRPTR cca_Str;
  87. };
  88. extern struct  CatCompArrayType CatCompArray[];
  89. #endif
  90.  
  91. #define SI(i)  GetString(i)
  92.  
  93.  
  94. #define CkErr(expression)  {if (!error) error = (expression);}
  95. #define ChunkMoreBytes(cn)    (cn->cn_Size - cn->cn_Scan)
  96. #define IS_ODD(a)        (a & 1)
  97.  
  98. #define IFF_OKAY    0L
  99. #define    CLIENT_ERROR    1L
  100. #define NOFILE          5L
  101.  
  102. #define message printf
  103.  
  104. /* Generic Chunk ID's we may encounter */
  105. #define    ID_ANNO        MAKE_ID('A','N','N','O')
  106. #define    ID_AUTH        MAKE_ID('A','U','T','H')
  107. #define    ID_CHRS        MAKE_ID('C','H','R','S')
  108. #define    ID_Copyright    MAKE_ID('(','c',')',' ')
  109. #define    ID_CSET        MAKE_ID('C','S','E','T')
  110. #define    ID_FVER        MAKE_ID('F','V','E','R')
  111. #define    ID_NAME        MAKE_ID('N','A','M','E')
  112. #define ID_TEXT        MAKE_ID('T','E','X','T')
  113. #define ID_BODY        MAKE_ID('B','O','D','Y')
  114.  
  115.  
  116. /* Used to keep track of allocated IFFHandle, and whether file is
  117.  * clipboard or not, filename, copied chunks, etc.
  118.  * This structure is included in the beginning of every
  119.  * form-specific info structure used by the example modules.
  120.  */
  121. struct ParseInfo {
  122.     /* general parse.c related */
  123.     struct  IFFHandle *iff;        /* to be alloc'd with AllocIFF */
  124.     UBYTE    *filename;        /* current filename of this ui */
  125.     LONG    *propchks;        /* properties to get */
  126.     LONG    *collectchks;        /* properties to collect */
  127.     LONG    *stopchks;        /* stop on these (like BODY) */
  128.     BOOL    opened;            /* this iff has been opened */
  129.     BOOL    clipboard;        /* file is clipboard */
  130.     BOOL    hunt;            /* we are parsing a complex file */
  131.     BOOL    Reserved1;        /* must be zero for now */        
  132.  
  133.     /* for copychunks.c - for read/modify/write programs
  134.      * and programs that need to keep parsed chunk info
  135.      * around after closing file.
  136.      * Deallocated by freechunklist();
  137.      */
  138.     struct Chunk *copiedchunks;
  139.  
  140.     /* application may hang its own list of new chunks here
  141.      * just to keep it with the frame.
  142.      */
  143.     struct Chunk *newchunks;
  144.  
  145.     ULONG    Reserved[8];
  146.     };
  147.  
  148.  
  149. /*
  150.  * Used by some modules to save or pass a singly linked list of chunks
  151.  */
  152. struct Chunk {
  153.     struct  Chunk *ch_Next;
  154.     long    ch_Type;
  155.     long    ch_ID;
  156.         long    ch_Size;
  157.         void    *ch_Data;
  158. };
  159.  
  160.  
  161. #ifndef NO_PROTOS
  162. /* parse.c */
  163. LONG openifile(struct ParseInfo *pi,UBYTE *filename, ULONG iffopenmode);
  164. void closeifile(struct ParseInfo *pi);
  165. LONG parseifile(struct ParseInfo *pi,LONG groupid,LONG grouptype,
  166.     LONG *propchks,LONG *collectchks,LONG *stopchks);
  167. LONG getcontext(struct IFFHandle *iff);
  168. LONG nextcontext(struct IFFHandle *iff);
  169. LONG currentchunkis(struct IFFHandle *iff, LONG type, LONG id);
  170. LONG contextis(struct IFFHandle *iff, LONG type, LONG id);
  171. UBYTE *findpropdata(struct IFFHandle *iff, LONG type, LONG id);
  172. void initiffasstdio(struct IFFHandle *iff);
  173. LONG chkcnt(LONG *taggedarray);
  174. long PutCk(struct IFFHandle *iff, long id, long size, void *data);
  175.  
  176. /* iffpstrings.c */
  177. UBYTE *openScreenErr(ULONG errorcode);
  178. UBYTE *IFFerr(LONG error);
  179. void OpenStrings(void);
  180. void CloseStrings(void);
  181. UBYTE *GetString(ULONG id);
  182.  
  183. /* copychunks.c */
  184. struct Chunk *copychunks(struct IFFHandle *iff,
  185.                  LONG *propchks, LONG *collectchks, ULONG memtype);
  186. void freechunklist(struct Chunk *first);
  187. struct Chunk *findchunk(struct Chunk *first, long type, long id);
  188. long writechunklist(struct IFFHandle *iff, struct Chunk *first);
  189. #endif /* NO_PROTOS */
  190.  
  191. #endif /* IFFP_IFF_H */
  192.